package com.jiazhong.basic.shuxin.net;

import lombok.SneakyThrows;

import java.io.InputStream;
import java.net.Socket;

public class DemoC2 {
    @SneakyThrows
    public static void main(String[] args) {
        // 客户端
        Socket socket = new Socket("192.168.7.11", 8888);
        System.out.println("通信端已经开启成功");
        // 接受内容
        InputStream in = socket.getInputStream();
        byte[] bytes = new byte[1024];
        int len = in.read(bytes);
        String message = new String(bytes, 0, len);
        System.out.println(message);
    }
}
